package ManagerSystem;

import java.util.Scanner;

import tjut.db.DBDriverFactory;
/**
 * 删除或恢复信息
 * @author ChrisL
 *
 */
public class DeleteInfo {

	public void DeleteStu(){
		Scanner input=new Scanner(System.in);
		System.out.println("1.删除数据       2.恢复数据");
		int choose=input.nextInt();
		SearchInfo si=new SearchInfo();
		switch(choose){
		case 1:
		   
		   si.SearchStu();
		   System.out.println("*************************************");
		   System.out.println("请输入你要删除的学生ID：");
		   String Stuid=input.next();
		   //建立标识列Isdelete,等于0时逻辑删除
		   String strSQL = "update MANAGERSYS set ISDELETE="+0+"where STU_ID=?";
		   int i =  DBDriverFactory.getDBDriverInstance().update(strSQL,new Object[] {Stuid});
		   System.out.println(i>0?"删除成功":"删除失败");
		   System.out.println("***************删除后***************");
		   si.SearchStu();
		break;
		case 2:
			
			si.SearchStu();
			System.out.println("*************************************");
			System.out.println("请输入你要恢复的学生ID：");
			String Stuid1=input.next();
			String strSQL1 = "update MANAGERSYS set ISDELETE="+1+"where STU_ID=?";
			int i1 =  DBDriverFactory.getDBDriverInstance().update(strSQL1,new Object[] {Stuid1});
			System.out.println(i1>0?"恢复成功":"恢复失败");
			System.out.println("***************恢复后***************");
			si.SearchStu();
			break;
		}
	}
}
